Machine Learning Models and Algorithms for Big Data Classification by Shan Suthaharan

Machine Learning Models and Algorithms for Big Data Classification by Shan Suthaharan

Author:Shan Suthaharan
Language: eng
Format: epub
Publisher: Springer US, Boston, MA


Listing 7.1 A Matlab example—standard regression

1 clear all;

2 close all;

3

4 %%% 1D Data Domain

5 x=[2 3 1 2 2.5];

6 y=[2 3 6 6.5 9.5];

7

8 A=y*x’*inv(x*x’);

9

10 xt=[0 4];

11 yt=A*xt;

12

13 figure;plot(x,y,’.’);axis([0 4 0 12]);grid on;

14 hold on;line(xt,yt);xlabel(’Feature␣1’);ylabel(’Feature␣2’);

15

16 %%% 2D Data Domain

17 x1=[2 3 1 2 2.5];

18 x2=[2 3 2.1 2 2.5];

19 yy=[2 3 6 6.5 9.5];

20

21 xx=[x1; x2];

22 AA=yy*xx’*inv(xx*xx’);

23

24 xx1=[0 0 4 4];

25 xx2=[0 4 0 4];

26 xxx=[xx1; xx2];

27

28 yy1=AA*xxx;

29 yy2=reshape(yy1,2,2);

30 [mg1,mg2]=meshgrid(0:4:4);

31

32 figure;plot3(x1,x2,yy,’r.’);grid on;axis([0 4 0 4 0 12]);

33 hold on;surf(mg1,mg2,yy2);view([259 44]);

34 xlabel(’Feature␣1’);ylabel(’Feature␣2’);zlabel(’Responses’);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.